package com.uk.ui.raporte;

import com.uk.data.ejbs.IFaturaBean;
import com.uk.ui.CHorizontalSplitPanel;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;


public class RaportePanel extends CHorizontalSplitPanel implements ItemClickListener, ValueChangeListener{

	
	private final RaporteNavigationTree raporteNavigationTree = new RaporteNavigationTree(this);
	private final IFaturaBean faturaBean;
	
	private RaporteQueryPanel raporteQueryPanel;
	
	
	public RaportePanel(IFaturaBean faturaBean) {
		super();
		this.faturaBean = faturaBean;
		this.setSplitPosition(150, CHorizontalSplitPanel.UNITS_PIXELS);
		this.setFirstComponent(this.raporteNavigationTree);
		
		this.raporteQueryPanel = new RaporteQueryPanel("Raport", faturaBean );
		
		
		
	}

	
	
	
	
	
	
	@Override
	public void valueChange(ValueChangeEvent event) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void itemClick(ItemClickEvent event) {
		if (event.getSource() == this.raporteNavigationTree){
			Object itemId = event.getItemId();
			if (RaporteNavigationTree.LIST_DEBITOR.equals(itemId)){
				this.raporteQueryPanel.setCaption(RaporteNavigationTree.LIST_DEBITOR.toString());
			}
			else if(RaporteNavigationTree.FATURA_PA_MBYLLUR.equals(itemId)){
				this.raporteQueryPanel.setCaption(RaporteNavigationTree.FATURA_PA_MBYLLUR.toString());
			}
			else if(RaporteNavigationTree.FATURA_ANULLUAR.equals(itemId)){
				this.raporteQueryPanel.setCaption(RaporteNavigationTree.FATURA_ANULLUAR.toString());
			}
			else if(RaporteNavigationTree.FATURA_PA_REGJISTRUAR.equals(itemId)){
				this.raporteQueryPanel.setCaption(RaporteNavigationTree.FATURA_PA_REGJISTRUAR.toString());
			}
			this.setSecondComponent(this.raporteQueryPanel);
		}
		
		
	}

}
